package com.parkinginfo.manager;

/*
 * Author: Deepika Gohil
 * 
 */

import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;

import com.parkinginfo.dbhelper.Place;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;


public class ParkingAdapter extends ArrayAdapter<GarageObject>
{
	private ArrayList<GarageObject> items; 
	private Context father;
	
	public ParkingAdapter(Context context, int textViewResourceId, ArrayList<GarageObject> items) 
	{
        super(context, textViewResourceId, items);
        this.father = context;
        this.items = items;
	}
	
	@Override
    public View getView(int position, View convertView, ViewGroup parent) 
	{
            View v = convertView;
            if (v == null) {
                LayoutInflater vi = (LayoutInflater)father.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.listing_items, null);
            }
           
            GarageObject p = items.get(position);
            if (p != null) {
            	
            	//Set address
            	TextView title = (TextView) v.findViewById(R.id.park_address);
                if (title != null) {
                	
                	title.setText(p.Address);     
                }
                
                //set available spaces
                TextView ava_spaces = (TextView) v.findViewById(R.id.ava_spaces);
                if (ava_spaces != null) {
                	
                	ava_spaces.setText("Available Spaces: " + p.available_spaces);     
                }
                
                //parking type
                TextView park_type = (TextView) v.findViewById(R.id.park_type);
                if (park_type != null) {
                	park_type.setText("Parking Type: " + p.type);   
                }
            }
            return v;
	}
}
